module(..., package.seeall) -- 使得文件中的函数在何处都可调用

require "pins"
require "config"
require "nvm"
nvm.init("config.lua", true)

local setGpio16Fnc = pins.setup(pio.P0_16, 1) -- 电磁阀吸合 0-正常 1-吸合
local setGpio17Fnc = pins.setup(pio.P0_17, 1) -- 报警灯 0-灯灭 1-灯亮
local manAutoSwitch, delayTime, solenoidValveOnOff = nvm.get("ManAutoSwitch"), nvm.get("DelayTime"),
    nvm.get("solenoidValveOnOff")


--高切中断
local function gpioInt27Fnc(msg)
    log.info("testGpioSingle.gpio27IntFnc", msg, getGpio27Fnc())
    if msg == cpu.INT_GPIO_NEGEDGE then
        setGpio16Fnc(0)
        setGpio17Fnc(0)
    elseif msg == cpu.INT_GPIO_POSEDGE then
        setGpio16Fnc(1)
        setGpio17Fnc(1)
    end
end
-- 上升沿中断时：msg为cpu.INT_GPIO_POSEDGE；下降沿中断时：msg为cpu.INT_GPIO_NEGEDGE
getGpio27Fnc = pins.setup(pio.P0_27, gpioInt27Fnc)
